home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Review 28
/
Creative-Review-CD-ROM-28.iso
/
mac
/
kungfu
/
assets
/
game.dir
/
00004_Script_joystick manager class
< prev
next >
Wrap
Text File
|
1997-08-08
|
3KB
|
159 lines
-- joy stick manager class
-- --------------------------------------------------
-- this tracks the control ( left ) and option ( right ) keys
-- with regular checks
-- informs player of changes of direction with mjoystick
-- --------------------------------------------------
property updategap
property leftcode
property rightcode
property leftflag
property rightflag
property direction
property changeflag
global gplayer, gtime, gkeylist, gjoylist, gpoll
-- ==================================================
-- new method
-- --------------------------------------------------
on new me
minit me
return me
end mnew
-- ==================================================
-- minit method
-- --------------------------------------------------
on minit me
-- put " in minit joystick"
set leftcode = the left of gjoylist
set rightcode = the right of gjoylist
mnonedown me
set changeflag = false
set updategap = 5
maddtask gtime, me, the timer + updategap
end minit me
-- ==================================================
-- mdotask method
-- --------------------------------------------------
on mdotask me
-- put "* in mdotask joystick"
set changeflag = false
case direction of :
#none:
if monekey ( gpoll, leftcode ) then mleftdown (me)
else if monekey ( gpoll, rightcode ) then mrightdown (me)
#left:
if not ( monekey ( gpoll, leftcode ) ) then mnonedown (me)
if rightflag then
if not monekey ( gpoll, rightcode ) then set rightflag = false
else if monekey ( gpoll, rightcode ) then mrightdown (me)
#right:
if not ( monekey ( gpoll, rightcode ) ) then mnonedown (me)
if leftflag then
if not ( monekey ( gpoll, leftcode ) ) then set leftflag = false
else if ( monekey ( gpoll, leftcode ) ) then mleftdown (me)
#up:
#upright:
#upleft:
end case
if changeflag then
-- put "ò new direction: " , direction
mjoystick ( gplayer , direction)
end if
return updategap
end mdotask
-- ==================================================
-- mrightdown method
-- --------------------------------------------------
on mrightdown me
-- put "in mrightdown"
set direction = #right
set rightflag = true
set changeflag = true
-- put "out mrightdown"
end mrightdown me
-- ==================================================
-- mleftdown method
-- --------------------------------------------------
on mleftdown me
-- put "in mleftdown"
set direction = #left
set leftflag = true
set changeflag = true
-- put "out mleftdown"
end mleftdown me
-- ==================================================
-- mnonedown method
-- --------------------------------------------------
on mnonedown
set direction = #none
set leftflag = false
set rightflag = false
set changeflag = false
end mnonedown
-- ==================================================
-- mgetlastest method
-- --------------------------------------------------
on mgetlatest me
-- put "in mgetlatest joy"
if direction = #none then return 0
else return direction
-- put "out mgetlatest joy"
end mgetlatest